package com.gitee.ywj1352.bussiness.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class UserClient {

    @Autowired
    RestTemplate restTemplate;


    public Long addUser(String username){
        String url = "http://127.0.0.1:8084/user?username=" + username;
        try {
            ResponseEntity<Long> forEntity = restTemplate.getForEntity(url, Long.class);
            return forEntity.getBody();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
}
